// 宿舍管理
import httpInstance from "./http";

// 1、获取所有宿舍信息
export const getAllDormitoryApi = () => {
    return httpInstance.get("/all_dormitories");
}

// 2、提交表单数据
export const submitFormApi = (form) => {
    return httpInstance.post('/submitDormitoryForm', {
        data: form
    })
}   

// 3、检测和搜索宿舍
export const isDormitoryUsedApi = (building, room_name) => {
    return httpInstance.get('/checkRoomName', {
        params: { building, room_name }
    })
}

// 4、删除按钮
export const delDormitoryApi = (id) => {
    return httpInstance.delete('/del_dormitory', {
        params: { id }
    })
}

// 5、根据宿舍楼和宿舍号获取该宿舍的所有宿舍成员
export const getAllNumbersApi = (building, room_name) => {
    return httpInstance.get('/dormitory_numbers', {
        params: {
            building,
            room_name
        }
    })
}

// 6、修改寝室长
export const addDorLeaderApi = (building, room_name, sno) => {
    return httpInstance.put('/add_dormitory_leader', { 
        building,
        room_name,
        sno
    })
}

// 7、根据宿舍楼和宿舍号获取宿舍的id值
export const getDorIdApi = (building, room_name) => {
    return httpInstance.get('/dormitory_id', {
        params: { building, room_name }
    })
}
